package creators;

import java.util.Scanner;

import simulation.FixedMass;
import simulation.Mass;
import simulation.Model;

/**
 * creator for a Mass or FixedMass object.
 * @author Schwartz & Roy
 *
 */
public class MassCreator extends Creator {

    /**
     * creates the object.
     * @param model is the model
     * @param line is the input
     */
    @Override
    public void create(Model model, Scanner line) {
        int id = line.nextInt();
        double x = line.nextDouble();
        double y = line.nextDouble();
        double mass = line.nextDouble();
        if (mass >= 0) {
            model.add(id, new Mass(x, y, mass));
        } else {
            //negative mass indicates fixed mass
            model.add(id, new FixedMass(x, y, -mass));
        }
    }
}
